package com.cskaoyan.controller.vx.collect;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.vxBo.collect.VXCollectAddOrDeleteBo;
import com.cskaoyan.bean.bo.vxBo.collect.VxCollectListBo;
import com.cskaoyan.bean.po.wxPo.CollectionListPo;
import com.cskaoyan.bean.po.wxPo.MarketUser;
import com.cskaoyan.bean.vo.TVO;
import com.cskaoyan.service.vx.collect.VXCollectService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 陈慧颖
 * @time: Created by chy on 2022/6/9 14:03
 */
@RestController
@RequestMapping("wx/collect")
public class VXCollectController {

    @Autowired
    VXCollectService collectService;

    @RequestMapping("addordelete")
    public BaseRespVo addordelete(@RequestBody VXCollectAddOrDeleteBo vxCollectAddOrDeleteBo) {

        System.out.println("vxCollectAddOrDeleteBo = " + vxCollectAddOrDeleteBo);
        collectService.addordelete(vxCollectAddOrDeleteBo);
        return BaseRespVo.ok(null);

    }

    @RequestMapping("list")
    public BaseRespVo list(VxCollectListBo vxCollectListBo) {
        Integer page = vxCollectListBo.getPage();
        Integer limit = vxCollectListBo.getLimit();
        Integer type = vxCollectListBo.getType();
        Subject subject = SecurityUtils.getSubject();
        MarketUser marketUser = (MarketUser) subject.getPrincipals().getPrimaryPrincipal();
        TVO<CollectionListPo> tvo = collectService.queryCollectList(marketUser.getId(), type, page, limit);
        return BaseRespVo.ok(tvo);
    }

}
